//
//  STLContainers.cpp
//  learnC++
//
//  Created by liuzhibing on 2018/7/1.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#include "STLContainers.hpp"

std::ostream& operator<<( std::ostream& os, const Book& book ){
    if(os){
        os << book.book_name_;
    }
    return os;
}


void traverse( std::vector<Book>& shelf, callback visit ){// 不使用迭代器遍历
    int sz = shelf.size();
    for( int i = 0; i < sz; ++i ){
        visit( shelf[i] );
    }
}

void traverse1( Shelf::iter b, Shelf::iter e, callback visit ){// 使用迭代器遍历
    while( b != e ){
        visit(*b);
        ++b;
    }
}

void visit(Book& book){
    std::cout << book << std::endl;
}
